<template>
	<view>
		<uni-card :title="'账号:'+ username" extra="">
			<text class="uni-body">
				<uni-data-checkbox mode="tag" v-model="radio" :localdata="list"></uni-data-checkbox>
				<uni-easyinput v-model="jine" placeholder="其他金额" @change="qita()" />
				<text class="xianshi">支付金额：{{radio}}元</text>
				<button class="button" type="primary" @click="chongz()">立即充值</button>
			</text>
		</uni-card>
	</view>
</template>

<script>
import { baseDefaultUrl } from '../../config/config'
	export default {
		data() {
			return {
				radio: 10,
				username: '',
				jine: '',
				list: [{
					text: '10元',
					value: 10
				}, {
					text: '50元',
					value: 50
				}, {
					text: '100元',
					value: 100
				}],
			}
		},
		onShow() {
			this.username = uni.getStorageSync('phone')
		},
		methods: {
			qita() {
				this.radio = this.jine
			},
			chongz() {
				uni.request({
					url: baseDefaultUrl + "/inter/user/chongzhi",
					method:'POST',
					header:{
						'Authorization':uni.getStorageSync('token')
					},
					data:{
						username:this.username,
						jine:this.radio
					},
					success: (res) => {
						if(res.data.code != 0){
							uni.navigateBack({
								delta: 1,
								success: function() {
									setTimeout(function() {
										uni.showToast({
											title: "充值成功",
											icon: 'success',
											duration: 2000
										});
									}, 500);
								}
							});
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none'
							});
						}
					}
				})
			}
		}
	}
</script>

<style scoped>
	/deep/ .uni-card .uni-card__header .uni-card__header-content .uni-card__header-content-title {
		font-size: 30rpx;
		font-weight: bolder;
		line-height: 60rpx;
	}
	/deep/.uni-data-checklist .checklist-group .checklist-box.is--tag {
		padding: 15rpx 30rpx;
		margin-bottom: 20rpx;
	}
	.xianshi {
		line-height: 80rpx;
		font-size: 30rpx;
		font-weight: bolder;
	}
</style>